import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:series_play/pages/search/controller/search_controller.dart'
    as search;
import 'package:series_play/widget/app_color.dart';
import 'package:series_play/widget/app_text.dart';
import 'package:series_play/widget/series_tag.dart';

import '../../comm/base/base_state.dart';

class SearchResultPage extends StatefulWidget {
  final search.SearchController searchController;

  const SearchResultPage(this.searchController, {super.key});

  @override
  State<SearchResultPage> createState() => _SearchResultPageState();
}

class _SearchResultPageState extends BaseState<SearchResultPage> {
  search.SearchController get mController => widget.searchController;

  @override
  Widget buildPage(BuildContext context) {
    return ListView.separated(
      padding: const EdgeInsets.all(14).w,
      itemBuilder: (context, index) {
        final item = mController.dataList[index];
        return SizedBox(
          height: 100.w,
          child: Row(
            children: [
              Container(
                height: 100.w,
                width: 76.w,
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: NetworkImage(item),
                    fit: BoxFit.cover,
                  ),
                  borderRadius: BorderRadius.circular(8).r,
                ),
              ),
              10.horizontalSpace,
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    AppText.title('标题名', color: AppColor.white),
                    10.verticalSpace,
                    Expanded(
                      child: Wrap(
                        runSpacing: 6.w,
                        spacing: 6.w,
                        children: [SeriesTag('tag')],
                      ),
                    ),
                    10.verticalSpace,
                    AppText(
                      '介绍介绍介绍介绍介绍介绍介绍介绍介绍',
                      color: AppColor.white_40,
                      fontSize: 13,
                      maxLines: 2,
                    ),
                  ],
                ),
              ),
            ],
          ),
        );
      },
      separatorBuilder: (context, index) {
        return 10.verticalSpace;
      },
      itemCount: mController.dataList.length,
    );
  }

  @override
  Color getBackgroundColor() {
    return Colors.transparent;
  }

  @override
  bool hideAppbar() => true;
}
